/*
 * Copyright (c) 2018 maoyan.com
 * All rights reserved.
 *
 */
package com.darren.euc.action;

import com.darren.euc.entity.MeetingroomOrderVO;
import com.darren.euc.entity.PageBean;
import com.darren.euc.entity.ResponseJSON;
import com.darren.euc.service.MeetingroomOrderService;
import com.darren.euc.service.MeetingroomService;
import com.darren.euc.util.PropertyHelper;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 在这里编写类的功能描述
 *
 * @author fangwenhao
 * @created 2018/3/13
 */
@Controller
@RequestMapping("/meetingRoomOrder")
public class MeetingRoomOrderAction {

    @Autowired
    private MeetingroomService meetingroomService;

    @Autowired
    private MeetingroomOrderService meetingroomOrderService;

    /**
     * 查询订单
     * @param requestJson
     * @param response
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value="/query",method = RequestMethod.POST)
    public ResponseJSON query(@RequestBody JSONObject requestJson, HttpServletResponse response, HttpServletRequest request){
        PageBean pageBean = meetingroomOrderService.queryV2(requestJson.getJSONObject("data"), 20, requestJson.getInt("currentPage"));
        return new ResponseJSON().setData(pageBean);
    }


    /**
     * 查看订单
     * @param requestJson
     * @param response
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value="/queryOne",method = RequestMethod.POST)
    public ResponseJSON queryOne(@RequestBody JSONObject requestJson, HttpServletResponse response, HttpServletRequest request){
        MeetingroomOrderVO meetingroomOrderVO = meetingroomOrderService.queryOne(requestJson.getJSONObject("data"));
        return new ResponseJSON().setData(meetingroomOrderVO);
    }

    /**
     * 查看订单 GET
     * @param orderId
     * @param response
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value="/queryOneV2",method = RequestMethod.GET)
    public ResponseJSON queryOne(@RequestParam Integer orderId, HttpServletResponse response, HttpServletRequest request){
        MeetingroomOrderVO meetingroomOrderVO = meetingroomOrderService.queryOne(orderId);
        return new ResponseJSON().setData(meetingroomOrderVO);
    }

}
